package Demo3_2;

public class Demo3_2 {
    public static void main(String[] args) throws InterruptedException {
        //获取main线程引用
        Thread Myymain = Thread.currentThread();

        Thread t = new Thread(() -> {
            try {
                System.out.println("等待main线程");
                Myymain.join();
                System.out.println("等待main线程完成");
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });

        t.start();

        for (int i = 0; i < 10; i++) {
            System.out.println("hello main");
            Thread.sleep(1000);
        }
    }
}
